package manager;

import org.hibernate.SessionFactory;
import org.hibernate.cfg.AnnotationConfiguration;
import org.hibernate.cfg.Configuration;
import org.hibernate.service.ServiceRegistry;
import org.hibernate.service.ServiceRegistryBuilder;

/**
 * 持久化管理
 * @author 凯
 *
 */
public class PersistentManager {
	
	private SessionFactory sf = null;
	
	private static PersistentManager sharedManager2 = new PersistentManager();

	public static PersistentManager sharemanager()
	{
		return sharedManager2;
	}
	
	public PersistentManager() {
		Configuration cfg = new Configuration().configure();
		ServiceRegistry serviceRegistry = new ServiceRegistryBuilder().applySettings(cfg.getProperties()).build();
		sf = cfg.buildSessionFactory(serviceRegistry);


	}
	
	/**
	 * 获取链接
	 * @return
	 */
	public SessionFactory getSessionFactory()
	{
		return sf;
	}
	

}
